const http = require('http')

http.createServer(function (request, response) {
    console.log('request come', request.url)
    response.writeHead(200, {
        'Access-Control-Allow-Origin': 'http://localhost:8888',  // 允许的域
        'Access-Control-Allow-Headers': 'X-Test-Cors',  // 允许的请求头
        'Access-Control-Allow-Methods': 'PUT, DELETE',  // 允许的请求方式
        'Access-Control-Max-Age': '1000',  // 允许的跨域请求最大时间（在1000ms内不需要再发送预请求进行验证）
    })
    response.end('corsServer is running')
}).listen(8887)

console.log('server listening on 8887')